package edu.yctc.manage.enums;

import com.google.common.collect.ImmutableList;

import java.util.List;

/**
 * @ClassName Gender
 * @Description TODO
 * @Author zyj
 * @Date 2021/3/29 22:21
 * @Version 1.0
 **/
public class Gender {

    /**
     * 男
     */
    public static final int MALE = 1;
    /**
     * 女
     */
    public static final int FEMALE = 2;

    public static final List<Integer> ALL_GENDERS = ImmutableList.of(MALE, FEMALE);

    public static boolean isLegal(int status) {
        for (Integer integer : ALL_GENDERS) {
            if (integer == status) {
                return true;
            }
        }
        return false;
    }

    public static String getGenderValue(int gender) {
        if (isLegal(gender)) {
            return gender == MALE ? "男" : "女";
        } else {
            return null;
        }
    }

    public static int getDBGenderValue(String gender) {
        if (gender.equals("男")) {
            return MALE;
        } else if (gender.equals("女")) {
            return FEMALE;
        }
        return 0;
    }
}
    